<template>
	<view>
		<view class="order-views">
			<view class="grid-box">
				<view class="u-flex">
					<view class="u-m-r-20"><u-icon name="clock" size="80" :color="$u.color.infoDark"></u-icon></view>
					<view class="u-flex-1">
						<view class="head-title u-m-b-10"><text>{{orderForm.managestate}}</text></view>
						<view class="tips-txt">订单{{orderForm.managestate}}</view>
					</view>
				</view>
			</view>
			<view class="grid-box">
				<view class="head-title u-m-b-20"><text>订单信息</text></view>
				<view class="msg-box">
					<view class="item">
						<text class="label">订单编号：</text>
						<view class="u-flex u-flex-1">
							<view class="u-flex-1">
								<view class="text">{{orderForm.number}}</view>
							</view>
							<view>
								<text class="u-tips-color u-p-l-20 copy" @click="copy(orderForm.number)">复制</text>
							</view>
						</view>
					</view>
					<view class="item">
						<text class="label">下单时间：</text>
						<view class="text">{{$u.timeFormat(orderForm.createddatetime, 'yyyy-mm-dd hh:MM:ss')}}</view>
					</view>
					<view class="item">
						<text class="label">上门时间：</text>
						<view class="text" v-if="orderForm.doortime">{{$u.timeFormat(orderForm.doortime, 'yyyy-mm-dd hh:MM:ss')}}</view>
						<view class="text" v-else>尽快上门</view>
					</view>
					<view class="item" v-if="orderForm.brotherdoortime">
						<text class="label">小哥上门：</text>
						<view class="text">{{$u.timeFormat(orderForm.brotherdoortime, 'yyyy-mm-dd hh:MM:ss')}}</view>
					</view>
					<view class="item">
						<text class="label">需求回收品：</text>
						<view class="text">
							<u-tag 
								class="u-m-l-5"
								v-for="(item, index) in orderForm.estimated" 
								:key="index"
								:text="item.names" 
								type="info" 
								size="mini"
							/>
						</view>
					</view>
					<view class="item" @click="seePhoto(0)">
						<text class="label">用户拍照：</text>
						<view class="text">
							<view class="u-flex" style="justify-content: flex-end;">
								<view class="u-m-l-10" v-for="(item,index) in orderForm.pics" :key="index">
									<u-image width="60rpx" height="60rpx" :src="utils.getPic(item)" shape="circle" @click="seePhoto(orderForm.pics,index)"></u-image>
								</view>
							</view>
						</view>
					</view>
					<view class="item" @click="seePhoto([orderForm.signinpic],0)">
						<text class="label">小哥上门拍照：</text>
						<view class="text">
							<view class="u-flex" style="justify-content: flex-end;">
								<view class="u-m-l-10">
									<u-image width="60rpx" height="60rpx" shape="circle" :src="utils.getPic(orderForm.signinpic)"></u-image>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			
			<view class="grid-box">
				<view class="u-table-box">
					<view class="head-title u-m-b-20"><text>回收汇总</text></view>
					<!-- <view>{{orderForm.details}}</view> -->
					<!-- <goods-list :orderId="orderId" :details="orderForm.details"></goods-list> -->
					<goods-table :details="confirmForm.details"></goods-table>
				</view>
				<view class="total">
					<text>共{{orderForm.details.length}}种回收品 合计:</text>
					<text class="total-price">
						￥{{orderForm.amount==0?'--':orderForm.amount.toFixed(2)}}
						<!-- <text class="decimal">00</text> -->
					</text>
				</view>
			</view>
			<view class="grid-box" v-if="orderForm.ordercomments">
				<view class="head-title u-m-b-10"><text>用户点评</text></view>
				<view class="comment-box u-p-0">
					<view class="hd u-font-30">平台服务</view>
					<view class="u-flex">
						<text class="label">便捷性：</text>
						<u-rate v-model="orderForm.ordercomments.convenience"></u-rate>
					</view>
					<view class="u-flex">
						<text class="label">操作性：</text>
						<u-rate v-model="orderForm.ordercomments.operability"></u-rate>
					</view>
					<view class="hd">小哥服务</view>
					<view class="u-flex">
						<text class="label">穿着整齐：</text>
						<u-rate v-model="orderForm.ordercomments.dresssharp"></u-rate>
					</view>
					<view class="u-flex">
						<text class="label">服务态度：</text>
						<u-rate v-model="orderForm.ordercomments.serviceattitude"></u-rate>
					</view>
					<view class="u-flex">
						<text class="label">业务能力：</text>
						<u-rate v-model="orderForm.ordercomments.businesscapability"></u-rate>
					</view>
					<view class="hd u-font-30">点评</view>
					<u-input type="textarea" :border="true" :disabled="true" placeholder="暂无点评" v-model="orderForm.ordercomments.remarks" />
				</view>
			</view>
			
			<view class="grid-box" v-if="orderForm.remarks">
				<view class="head-title u-m-b-20"><text>订单备注</text></view>
				<view class="msg-box">
					<u-input v-model="orderForm.remarks" type="textarea" border input-align="left" placeholder="请输入备注"/>
				</view>
			</view>
			<view class="grid-box" v-if="process.length > 0">
				<view class="head-title u-m-b-30"><text>订单进程</text></view>
				<u-time-line>
					<u-time-line-item v-for="(item,index) in process" :key="index">
						<!-- 此处没有自定义左边的内容，会默认显示一个点 -->
						<template v-slot:content>
							<view>
								<view class="u-order-title u-m-b-10">{{item.state}}</view>
								<view class="u-order-desc" v-if="item.remarks">
									<text v-if="item.state == '已取消'">取消原因：</text>
									<text>{{item.remarks}}</text>
								</view>
								<view class="u-order-time"><u-icon name="calendar-fill"></u-icon>{{$u.timeFormat(item.createddatetime, 'yyyy-mm-dd hh:MM:ss')}}</view>
							</view>
						</template>
					</u-time-line-item>
				</u-time-line>
			</view>
			
			<view class="navigation">
				<view class="right">
					<u-button class="navbtn" @click="back">返回</u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import uniCopy from '@/common/xb-copy/uni-copy.js'
	
	import {
		mapState
	} from 'vuex';
	
	export default {
		props:{
			orderId: 0,
			orderForm: {}
		},
		data() {
			return {
				process: [],
				confirmForm:{
					details:[]
				}
			}
		},
		computed: {
			...mapState({
				userdetail: state => state.userdetail,
				header: state => state.Authorization
			})
		},
		created() {
			this.getProcess()
			this.orderForm.details.forEach((item)=>{
				item.details.forEach((cell)=>{
					this.confirmForm.details.push({
						"show": false,
						"id": cell.productid,
						"price": cell.price,
						"weight": cell.weight,
						"amount": cell.amount,
						"typeremarks": cell.remarks,
						"allowedit": true,
						"minprice": 0,
						"highprice": 0,
						"err": false,
						"typenames": item.names,
						"name": cell.productname,
						"isweighing": cell.isweighing,
						"typeid": item.id,
						"pic": item.icon,
						"on": true
					})
				})
			})
		},
		methods: {
			back(){
				uni.navigateBack()
			},
			// 复制方法
			copy(font) {
				uniCopy({
					content:font,
					success:(res)=>{
						uni.showToast({
							title: res,
							icon: 'none'
						})
					},
					error:(e)=>{
						uni.showToast({
							title: e,
							icon: 'none',
							duration:3000,
						})
					}
				})
			},
			// 获取订单流程
			getProcess(){
				this.$u.get('/User/Order/Process?id=' + this.orderId).then((res)=>{
					this.process = res
				})
			},
			seePhoto(imgArr = [],current) {
				let url = []
				imgArr.forEach((item)=>{
					url.push(this.utils.getPic(item))
				})
				uni.previewImage({
					current: current,
					urls: url
				});
			},
		}
	}
</script>

<style lang="scss" scoped>
	.order-views{
		min-height: calc(100vh - 123px);
	}
	// 点评
	.comment-box{
		padding: 60rpx;
		width: 600rpx;
		.hd{
			border-bottom: 1px solid $u-border-color;
			padding: 20rpx 0;
			margin-bottom: 20rpx;
			font-size: 32rpx;
		}
		.u-flex{
			margin: 10rpx 0;
			.label{
				color: $u-content-color;
			}
		}
	}

	// 订单
	.order {
		// width: 690rpx;
		// background-color: #ffffff;
		// margin: 30rpx auto;
		// border-radius: 30rpx;
		// box-sizing: border-box;
		// padding: 30rpx;
		// font-size: 28rpx;
		// box-shadow: $u-color-border-shadow;
		.top {
			display: flex;
			justify-content: space-between;
			.left {
				display: flex;
				align-items: center;
				.store {
					margin: 0 10rpx;
					font-size: 32rpx;
					font-weight: bold;
				}
			}
			.right {
				color: $u-type-warning-dark;
			}
		}
		.item {
			display: flex;
			margin: 20rpx 0 0;
			justify-content: space-between;
			.left {
				margin-right: 20rpx;
				image {
					width: 160rpx;
					height: 160rpx;
					border-radius: 10rpx;
				}
			}
			.content {
				.title {
					font-size: 28rpx;
					line-height: 50rpx;
				}
				.type {
					margin: 10rpx 0;
					font-size: 24rpx;
					color: $u-tips-color;
				}
				.delivery-time {
					color: $u-tips-color;
					font-size: 24rpx;
				}
			}
			.right {
				margin-left: 10rpx;
				padding-top: 20rpx;
				text-align: right;
				.decimal {
					font-size: 24rpx;
					margin-top: 4rpx;
				}
				.number {
					color: $u-tips-color;
					font-size: 24rpx;
				}
			}
		}
		.total {
			margin-top: 20rpx;
			text-align: right;
			font-size: 24rpx;
			.total-price {
				font-size: 32rpx;
				color: $u-color-orange;
			}
		}
		.time{
			font-size: 24rpx;
			margin: 20rpx 0;
			line-height: 40rpx;
		}
		.bottom {
			display: flex;
			margin-top: 40rpx;
			padding: 0 10rpx;
			justify-content: space-between;
			align-items: center;
			.btn {
				line-height: 52rpx;
				width: 160rpx;
				border-radius: 26rpx;
				border: 2rpx solid $u-border-color;
				font-size: 26rpx;
				text-align: center;
				color: $u-type-info-dark;
				padding: 0 10rpx;
			}
			.evaluate {
				color: $u-type-warning-dark;
				border-color: $u-type-warning-dark;
			}
		}
	}
	// 按钮栏
	.navigation {
		display: flex;
		margin-top: 30rpx;
		border: solid 2rpx #f2f2f2;
		background-color: #ffffff;
		position: sticky;
		bottom: 0;
		z-index: 99;
		.right {
			display: flex;
			font-size: 28rpx;
			align-items: center;
			flex: 1;
			justify-content: space-around;
			padding: 20rpx;
			.navbtn{
				width: 100%;
				margin: 0 10rpx;
			}
			.btn {
				line-height: 66rpx;
				padding: 0 30rpx;
				border-radius: 36rpx;
				color: #ffffff;
				margin: 16rpx 0;
			}
			.cancel {
				margin-right: 30rpx;
				color: $u-tips-color;
			}
			.buy {
				background-color: #ff7900;
			}
		}
	}
	// 
	.u-table-box{
		margin: 20rpx 0;
		.green{
			background-color: $u-color-green;
			color: #fff!important;
		}
		.red{
			background-color: $u-color-red;
			color: #fff!important;
		}
	}
	.total {
		margin-top: 20rpx;
		text-align: right;
		font-size: 24rpx;
		.total-price {
			font-size: 32rpx;
			color: $u-color-orange;
		}
	}

	.u-line{
		border-bottom: 1px solid $u-border-color;
		padding-top: 30rpx;
		margin-bottom: 20rpx;
	}
	
	.u-order-title {
		color: #333333;
		font-weight: bold;
		font-size: 32rpx;
	}
	
	.u-order-desc {
		color: rgb(150, 150, 150);
		font-size: 28rpx;
		margin-bottom: 6rpx;
	}
	
	.u-order-time {
		color: rgb(200, 200, 200);
		font-size: 26rpx;
	}
</style>
